
#include <vector>
#include <string>

using namespace std;


class Solution {
public:
	int reverse(int x) {
		string s = to_string(x);

		int l = 0; int r = s.size() - 1;
		int flag = 0;
		if (s[0] == '-') {
			s = s.substr(1);
			flag = 1;
		}

		::reverse(s.begin(), s.end());

		long long ans = atoll(s.c_str());
		if (flag) ans = -ans;

		if (ans > INT_MAX || ans < INT_MIN) return 0;

		return (int)ans;
	}


};


//int main() {
//	Solution s;
//	s.reverse(1232341);
//	return 0;
//}